﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Transactions;
using T.FAS.Runtime.Base.Common;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Base.Service
{
    public class BuildServerService
    {
        private static readonly object syncObject = new object();
        private static BuildServerService instance;
        private BuildServer _buildServer;
        private static readonly object _lock = new object();
        public static BuildServerService GetInstance()
        {
            if (instance == null)
            {
                lock (syncObject)
                {
                    if (instance == null)
                        instance = new BuildServerService();
                }
            }
            return instance;
        }
        /// <summary>
        /// 获取当前机器信息
        /// </summary>
        public BuildServer BuildServer
        {
            get
            {
                if (_buildServer == null)
                {
                    lock (_lock)
                    {
                        if (_buildServer == null)
                        {
                            try
                            {
                                _buildServer = new BuildServerDao().GetObject(ConfigUtil.Instance.GenerateCodeBuildServer);
                            }
                            catch
                            {
                                _buildServer = null;
                            }
                        }
                    }
                }
                return _buildServer;
            }
        }
    }
}
